package demoStuden;

public class Student implements Comparable{
    private String name;
    private  int score;
    public Student(String name,int score){
        this.name = name;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        Student s = (Student) o;
        if(this.score > s.score){
            return -1;
        }
        else return 1;
    }

    public static void main(String[] args) {
        Student student1 = new Student("张三",90);
        Student student2 = new Student("李四",99);
        System.out.println(student1.compareTo(student2));
    }
}
